package com.grandt.model.configuration;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

import com.grandt.model.constants.ConstantsConfiguration;



public class ManagerConfiguation {
	private Properties properties;
	public ManagerConfiguation() {	
	}
	public ConfigurationBean load(String path) throws FileNotFoundException, IOException{
		properties = new Properties();
		properties.load(new FileInputStream(path));
		ConfigurationBean configuration= new ConfigurationBean();
		configuration.setDriver(getProperty(ConstantsConfiguration.driver));
		configuration.setUrl(getProperty(ConstantsConfiguration.url));
		configuration.setUser(getProperty(ConstantsConfiguration.user));
		configuration.setPassword(getProperty(ConstantsConfiguration.password));
		return configuration;
	}
    public String getProperty(ConstantsConfiguration constant){
        String keyPath = "grandt.";
        return properties.getProperty(keyPath+constant.getRelativePath(), String.valueOf(constant.getValue()));
    }

}
